/* ############################################################################
*
* Name             : fckplugin.js
* Description      : Infopopup Plug-In for FCKeditor
*                    Info-Popups to Text
* Part of          : phpwcms-XT
* Author           : Horst-D. Kroeller
* Version          : 1.1.0
* Date             : 09.07.2006 12:39
* Copyright        : 2006 by Author
*
* You can redistribute it and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;either version 2
* of the License, or (at your option) any later version.
*
* General Public License can be found at http://www.gnu.org/copyleft/gpl.html
*
* This script is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* This Copyright Notice MUST APPEAR in all copies of the script!
*
* -----------------------------------------------------------------------------
* Changelog        :
*
#############################################################################*/

// Register the related command.
FCKCommands.RegisterCommand( 'InfoPopUp', new FCKDialogCommand( 'InfoPopUp', FCKLang.InfoPopUpDlgTitle, FCKPlugins.Items['InfoPopUp'].Path + 'fck_infopopup.html', 340, 400 ) ) ;

// Create the "InfoPopUp" toolbar button.
var oInfoPopUpItem = new FCKToolbarButton( 'InfoPopUp', FCKLang.InfoPopUpBtn ) ;
oInfoPopUpItem.IconPath = FCKPlugins.Items['InfoPopUp'].Path + 'infopopup.gif' ;
FCKToolbarItems.RegisterItem( 'InfoPopUp', oInfoPopUpItem ) ;

// The object used for all InfoPopUp operations.
var FCKInfoPopUp = new Object() ;

// Insert a new href with mouseover- and mouseout-Handlers to show/hide the InfoPopUp at the actual selection.
FCKInfoPopUp.Insert = function( shtml,val,ehtml,puid ){
	var hrefStartHtml = '<a class="infopopup_highlight" onmouseout="hide_infopopup()" onmouseover="show_infopopup(\''+val+'\')"> ';
	var hrefEndHtml = '</a>';

if (window.getSelection) {
	mySelection = FCK.EditorWindow.getSelection();
}
else if (document.getSelection){
	mySelection = FCK.EditorDocument.getSelection();
}
else if (document.selection) {
	mySelection=FCK.EditorDocument.selection.createRange().text;
}
hrefHtml = hrefStartHtml+mySelection;

	FCK.InsertHtml(hrefHtml);
	tmpHtml = FCK.GetHTML();
	FCK.SetHTML(tmpHtml,true);
}
